package com.tezign.intelligence.mini.dam.aifamilyconsultant.util;

import com.tezign.intelligence.mini.dam.aifamilyconsultant.entity.Session;
import com.tezign.intelligence.mini.dam.aifamilyconsultant.service.ISessionService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * todo
 *
 * @Author ouyangkang
 * @date 2024/12/27
 */
@Component
@Slf4j
@RequiredArgsConstructor
public class DataCleanUtil {

	private final ISessionService sessionService;

	public void sessionContentEncrypt() {
		List<Session> sessions = sessionService.list();
		for (Session session : sessions) {
			session.setContent(AESUtil.encrypt(session.getContent()));
		}
		sessionService.updateBatchById(sessions);
	}

	public void sessionContentDecrypt() {
		List<Session> sessions = sessionService.list();
		for (Session session : sessions) {
			session.setContent(AESUtil.decrypt(session.getContent()));
		}
		sessionService.updateBatchById(sessions);
	}

}
